using GrapeCity.Forguncy.Commands;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using EnumsNET;
using GrapeCity.Forguncy.Plugin;
using ImportDataToDataBaseExtensionPlugin.Helper;

namespace ImportDataToDataBaseExtensionPlugin.Designer
{
    public class ImportDataToDataBaseExtensionPluginServerCommandDesigner : CommandDesigner<ImportDataToDataBaseExtensionPluginServerCommand>
    {
        public override EditorSetting GetEditorSetting(PropertyDescriptor property, IBuilderCommandContext builderContext)
        {
            if (property.Name == nameof(ImportDataToDataBaseExtensionPluginServerCommand.DataBaseType))
            {
                return new ComboEditorSetting(
                    Enum.GetValues<DataBaseTypeEnum>().Select(e => new ComboItem((int)e, e.GetName())), 
                    nameof(ComboItem.Display), 
                    nameof(ComboItem.Value));
            }
            return base.GetEditorSetting(property, builderContext);
        }
    }
    
    public class ComboItem
    {
        public ComboItem(int value, string display)
        {
            Value = value;
            Display = display;
        }
        public int Value { get; set; }
        public string Display { get; set; }
    }
}
